home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 9 / FM Towns Free Software Collection 9.iso / t_os / shell / igo / gosource / gcell.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-16  |  1.4 KB  |  83 lines

  1. #define debug 0
  2. /* 
  3.     TOWNS囲碁棋譜記録プログラム
  4.                                           1993/07/25  久保田俊也
  5.  
  6.     93/07/25        banデ-タの親グル-プのセルを操作する関数の集まり 
  7.                 
  8.  
  9. */
  10. #include <stdlib.h>
  11. #include "igo.h"
  12. #include "banx.h"
  13.  
  14. static GCELL *gcell=NULL;
  15. static GCELL *free_p;
  16.  
  17. int gcell_init()
  18. {
  19. int i;
  20.  
  21.     if(gcell == NULL){
  22.         gcell = (GCELL *)my_malloc( sizeof(GCELL) * MAX_BANSIZE2);
  23.         if( gcell == NULL){
  24.             return -1;
  25.         }
  26.     }
  27.     
  28.     for(i=0;i<MAX_BANSIZE2-1;i++){
  29.         gcell[i].next = &gcell[i+1];
  30.         gcell[i].iro  = FREE_CELL; /* free_cell の意味で使っている */
  31.         gcell[i].dame_ptr = NULL;
  32.         gcell[i].territory_iro = BLANK;
  33.         gcell[i].henkan_territory_iro = BLANK;
  34.         gcell[i].dame_number = 0;
  35.     }
  36.     gcell[MAX_BANSIZE2-1].next = NULL;
  37.     gcell[MAX_BANSIZE2-1].iro  = FREE_CELL; /* free_cell の意味で使っている */
  38.     gcell[MAX_BANSIZE2-1].dame_ptr  = NULL;
  39.     gcell[MAX_BANSIZE2-1].territory_iro  = BLANK;
  40.     gcell[MAX_BANSIZE2-1].henkan_territory_iro  = BLANK;
  41.     gcell[MAX_BANSIZE2-1].dame_number  = 0;
  42.  
  43.     free_p = &gcell[0];
  44.     return 0;
  45.     
  46. }
  47.  
  48. int gcell_end()
  49. {
  50.  
  51.     if(gcell == NULL){
  52.         return -1;
  53.     }else{
  54.         my_free(gcell);
  55.         return 0;
  56.     }
  57.  
  58. }
  59.  
  60. GCELL *gcell_get()
  61. {
  62. GCELL *wk_te;
  63.  
  64.     if(free_p == NULL){
  65.         return NULL;
  66.     }else{
  67.         wk_te = free_p;
  68.         free_p = free_p->next;
  69.         return wk_te;
  70.     }
  71.  
  72. }
  73.  
  74. int gcell_free(GCELL *p)
  75. {
  76.  
  77.     p->next = free_p;
  78.     p->iro  = FREE_CELL;
  79.     free_p = p;
  80.     return 0;
  81. }
  82.  
  83.